home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / appsrcs.zip / APPBAR.ZIP / APPDROP.C < prev    next >
C/C++ Source or Header  |  1993-06-10  |  4KB  |  110 lines

  1. /* AppDrop.c */
  2.  
  3. /*
  4.    takes care of the handling of dropped files
  5. */
  6.  
  7. #define STRICT
  8. #include <windows.h>
  9. #include <windowsx.h>
  10. #include <string.h>
  11. #include <shellapi.h>
  12. #include "appbar.h"
  13.  
  14. VOID ProcessDropFiles(HANDLE hDrop, HICON *hIcon)
  15.     {
  16.     int    iDropButton = 0, iDropped;
  17.     char   szDropFile[MAXFILECHARS];
  18.     POINT  DropPoint;
  19.     UINT   i, DroppedFiles;
  20.  
  21.     DragQueryPoint(hDrop, (LPPOINT) &DropPoint);
  22.     iDropButton = (DropPoint.y/(AppWindow.cyButton+AppSystem.Border));
  23.     iDropButton += (AppWindow.nButtons/AppWindow.nColumns)*(DropPoint.x/(AppWindow.cxButton+AppSystem.Border));
  24.     DroppedFiles = DragQueryFile(hDrop, 0xFFFF, (LPSTR) NULL, 0);
  25.     iDropped = iDropButton-FirstAppButton;
  26.  
  27.     // Determine if we have to play the DropFile sound
  28.     if(AppSound.EnableSound != 0)
  29.     {
  30.     if(iDropped > 0)
  31.         {
  32.         if(AppButton[iDropped].NoSound == 0)
  33.         if(stricmp(AppSound.DropFile, "<none>") != 0)
  34.             sndPlaySound(AppSound.DropFile, SND_ASYNC | SND_NODEFAULT);
  35.         }
  36.     else
  37.         {
  38.         if(stricmp(AppSound.DropFile, "<none>") != 0)
  39.         sndPlaySound(AppSound.DropFile, SND_ASYNC | SND_NODEFAULT);
  40.         }
  41.     }
  42.  
  43.     if(!bQuickLoad)
  44.     {
  45.     if(iDropped >= 0)
  46.         {
  47.         if(!IsAppTip(iDropped))
  48.         {
  49.         for(i=0;i<DroppedFiles;i++)
  50.             {
  51.             DragQueryFile(hDrop, i, szDropFile, sizeof(szDropFile));
  52.             // add szDropfile to existing parameters.
  53.             lstrcpy((LPSTR) szBuffer, (LPSTR) AppButton[iDropped].Params);
  54.             lstrcat((LPSTR) szBuffer, (LPSTR) " ");
  55.             if(!strchr(szDropFile, '.'))
  56.             lstrcat((LPSTR) szDropFile, (LPSTR) ".");
  57.             lstrcat((LPSTR) szBuffer, (LPSTR) szDropFile);
  58.             ProgExec(hWndMain, AppButton[iDropped].ProgName, szBuffer, AppButton[iDropButton-FirstAppButton].StartDir, AppButton[iDropped].ShowMode);
  59.             }
  60.         }
  61.         else
  62.         {
  63.         lstrcpy((LPSTR) szBuffer, (LPSTR) " ");
  64.         for(i=0;i<DroppedFiles;i++)
  65.             {
  66.             DragQueryFile(hDrop, i, szDropFile, sizeof(szDropFile));
  67.             // add szDropfile to existing parameters.
  68.             if(lstrlen((LPSTR) szBuffer) + lstrlen((LPSTR) szDropFile) < 127)
  69.             {
  70.             lstrcat((LPSTR) szBuffer, (LPSTR) szDropFile);
  71.             lstrcat((LPSTR) szBuffer, (LPSTR) " ");
  72.             }
  73.             else
  74.             {
  75.             ProgExec(hWndMain, AppButton[iDropped].ProgName, szBuffer, AppButton[iDropButton-FirstAppButton].StartDir, AppButton[iDropped].ShowMode);
  76.             lstrcpy((LPSTR) szBuffer, (LPSTR) " ");
  77.             }
  78.             }
  79.         ProgExec(hWndMain, AppButton[iDropped].ProgName, szBuffer, AppButton[iDropButton-FirstAppButton].StartDir, AppButton[iDropped].ShowMode);
  80.         }
  81.         }
  82.     else
  83.         {
  84.         for(i=0;i<DroppedFiles;i++)
  85.         {
  86.         DragQueryFile(hDrop, i, szDropFile, sizeof(szDropFile));
  87.         ShellExecute(hWndMain, "open", szDropFile, NULL, NULL, SW_SHOWNORMAL);
  88.         }
  89.         }
  90.     }
  91.     if(bQuickLoad)
  92.     {
  93.     if(iDropped >= 0)
  94.         {
  95.         AppButton[iDropped] = AppEmptyButton;
  96.         DragQueryFile(hDrop, 0, szDropFile, sizeof(szDropFile));
  97.         strcpy(AppButton[iDropped].IcoName, szDropFile);
  98.         strcpy(AppButton[iDropped].ProgName, szDropFile);
  99.         SaveButtonIni(AppButton[iDropped], iDropped, (LPSTR) INI_BUTTON, (LPSTR) INI_FILE);
  100.         DestroyIcon(hIcon[iDropped]);
  101.         hIcon[iDropped] = ExtractIcon(hInst, AppButton[iDropped].IcoName, AppButton[iDropped].IconNumber);
  102.         if(hIcon[iDropped] == (HICON) 1)
  103.         hIcon[iDropped] = NULL;
  104.         InvalidateRect(hWndButton[iDropButton], NULL, FALSE);
  105.         UpdateWindow(hWndButton[iDropButton]);
  106.         }
  107.     }
  108.     DragFinish(hDrop);
  109.     }
  110.